package edu.wpi.cs509.clientlogic;

import java.util.List;

import edu.wpi.cs509.messages.client.MsgLoginReply;
import edu.wpi.cs509.representation.ActionBaseClass;
import edu.wpi.cs509.representation.ClientGame;
import edu.wpi.cs509.representation.GameListItem;
import edu.wpi.cs509.representation.TeamColor;
import edu.wpi.cs509.representation.UserStatistics;
import edu.wpi.cs509.ui.intfc.RulesInterface;

/*
 * This interface defines the methods that the Messages 
 * will invoke in the client logic during the response 
 * from the server logic.
 */
public interface ClientUpstreamInterface {

	/**
	 * Receives the server's response to the Login Message.
	 * @param loginResult - the result of the login request (good/invalid)
	 * @param session - The unique identifier for the user.
	 */
	void receiveLogin(MsgLoginReply.LoginResult loginResult);
	
	/**
	 * Receives the servers response to the Logout Message.
	 */
	void receiveLogout();
	
	/**
	 * Receives the servers response to the Leader Board Message.
	 * @param leaderBoardStats - The list of player statistics, which was
	 * 	requested by the UI.
	 * @param start_rank - The rank of the first player in the sorted list
	 */
	void receiveLeaderBoard(List<UserStatistics> leaderBoardStats, int start_rank);
	
	/**
	 * Receives the servers response to the Ranked Players Message.
	 * @param playerStats the stats for a player
	 * @param rank the rank of a player
	 */
	void receivePersonalStats(UserStatistics playerStats, int rank);
	
	/**
	 * Receives the servers response to the Request Games Message.
	 * @param games - List of all games, both joinable and observable.
	 */
	void receiveGames(List<GameListItem> games);
	
	
	/**
	 * Receives the servers response to the Start New Game Message.
	 * @param game - The client game object for the new game.
	 */
	void receiveStartNewGame (ClientGame game, boolean success, String errorMessage); 
	

	/**
	 * Receives the servers response to the Stratego Rules Message.
	 * @param rules - The rules for the game Stratego.
	 */
	void receiveStrategoRules(RulesInterface rules);
	
	/**
	 * Receives the Game Over message from the server.
	 * @param game - the updated client game instance
	 * @param winner - Whether the current player is the winner.
	 */
	void receiveGameOver(ClientGame game, boolean winner);
	
	/**
	 * Receives the Game Start Message from the server.
	 * @param game - the updated client game instance
	 */
	void receiveGameStarted(ClientGame game);
	
	/**
	 * Receives the Its Your Turn Message to tell the current user that it is their turn.
	 * @param game - the updated client game instance
	 */
	void receiveItsYourTurn(ClientGame game);
	
	/**
	 * Receives the Opponent Quit message.
	 * @param session - The unique identifier for the user.
	 */
	void receiveOpponentQuit(UserSession session);
	
	/**
	 * Receives the Piece Moved message from the server. 
	 * This handles both attack and non-attack messages.
	 * @param lastMove - the requested move (includes to/from/player-pc)
	 * @param session - The unique identifier for the user.
	 */
	void receivePieceMoved(ActionBaseClass lastMove, boolean success, ClientGame game,  
			UserSession session, TeamColor nextTurn);
	
	/**
	 * To refresh the game board.
	 */
	void receiveRefreshGameBoard();
	
	/**
	 * The connection will tell us that the connection was lost to the server.
	 */
	void receiveServerConnectionLost();

	/**
	 * Receives the game update from the server when the opponent has submitted their
	 * pieces after initial placement.
	 * @param game - the updated client game instance
	 */
	void receiveOpponentReady(ClientGame game);

	/**
	 * Receives the game update from the server when the opponent has joined our game.
	 * @param game - the updated client game instance
	 */
	void receiveOpponentJoined(ClientGame game);
	
}